home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Info-Mac 4
/
Info_Mac IV CD-ROM (Pacific HiTech Inc.)(August 1994).iso
/
Development
/
Source
/
Watch Volume Mount
/
MountVol init.c
< prev
next >
Wrap
C/C++ Source or Header
|
1993-11-22
|
2KB
|
51 lines
/*
***********************************************************************
*
* Messing around Mac System software
* This is a code resource - patch to the MounVol system trap
*
* The purpose of the patch is to intercept and save the drive ref number,
* which is passed as a parameter to the _MountVol system trap (PBMountVol from C).
* The saved device ref number can be retrieved by whoever is interested. The
* trick is the ref number is saved within the fixed offset from the entry point
* to this trap patch.
*
* Note! This is a code resource which is supposed to be installed as a
* trap-handler. Don't do anything stupid here! Don't call the ToolBox!
* The code must be position-independent. Nobody sets up registers to address
* the global variables: either use A4 addressing (but fon't forget to set
* up the A4 at the outset), or put the variables in the CODE segment and access
* them through PC (which is only one register which is for sure set up
* right).
*
* Interfaces
* a0 contains the ptr to the parameter block
* +22(a0) word contains the drive ref number for the volume to mount
* The standard _MountVol trap routine is entered after the drive ref number
* is saved.
*
***********************************************************************
*/
#define Signature 23547
long main(void)
{
asm {
bra @3 // Jump around our data
dc.w Signature
@1 dc.w 0 // driver ref number storage
@2 dc.l 0 // Ptr to the real trap program
@3
move.l a1,-(sp)
lea @1,a1
move.w 22(a0),(a1) // save the drive ref number
move.l (sp)+,a1
@4 move.l @2,-(sp) // Push the address of the real MountVol routine
// to the stack. RTS instruction that terminates
// main() would then pass the control to the
// real handler
}
} // Note, RTS is to be generated here. We count on it!